#ifndef __ARCH_CPU_H__
#define __ARCH_CPU_H__

#include <stdint.h>
#include <stdbool.h>
#include <arch.h>
#include <fences.h>

extern int plat_get_core_pos(uint64_t mpidr);
extern uint64_t _barrier;

static inline uint32_t get_cpuid()
{
    uint32_t mpidr = MRS(mpidr);

    return plat_get_core_pos(mpidr);
}

static inline void boot_secondarys(void)
{
    /**
     * 此时其他CPU都在boot.S .L__secondarys_wait处等待
     * _barrier写1即通知其他CPU继续执行
     */
    _barrier = 1;
    fence_sync_write();
    asm volatile("sev\n");
}

void cpu_arch_init(void);
void cpu_arch_idle(void);
#endif /* __ARCH_CPU_H__ */
